*8_qte_code_majors_june2022*
*created: 
*updated: 6-24-22 by Meredith Welch, based off 8_qte_code_majors_4yr_aug2021; 7-15-22 to adjust scales
*authors: 
*This code produces estimates for quantile treatment effect of major figures. 


/** SECTION 0: SET UP **/ 

global  outdir "/srv/tier1/projects/180_major/Majors"
global root "/srv/tier1/projects/180_major/Majors"
global data $root/1_data_cleaning/data 
global output_desc $root/2_data_analysis/desc_stats
global output_results $root/2_data_analysis/results
global tables $output_results/tables
global plots $output_results/plots 

cap log close
*log using $output_results/8_qte_code_majors_june2022.log, replace

clear all 
set more off
set matsize 11000
set seed 987654321
set sortseed 546813

pause on

*SET UP CONTROL MACROS 
*COMBINED SECTOR MAJORS MACRO
local major "ag com it voc eng bio sci soc bus und"
*Note: these are the control variables from Andrews, Li, Lovenheim (2014) Table 2 
local controls "z_math z_reading rank_90_math rank_7090_math rank_90_reading rank_7090_reading male white hispanic black asian gift atrisk econ_disad first_earn_year first_earn_qtr last_earn_year last_earn_qtr"
*DIFFERENT SECTORS MAJORS MACRO
local majors_4yr "ag_4yr bio_4yr bus_4yr com_4yr eng_4yr it_4yr lib_4yr sci_4yr soc_4yr und_4yr voc_4yr"
local majors_2yr "ag_2yr bio_2yr bus_2yr com_2yr educ_2yr eng_2yr it_2yr lib_2yr sci_2yr soc_2yr und_2yr voc_2yr"

*SET REPS FOR BOOTSTRAP
global reps = 200


 

/** SECTION 1: CREATE PROGRAM TO BOOTSTRAP QTE CALCULATION **/ 

capture program drop boot

*SET UP PROGRAM TO BOOTSTRAP THROUGH ANY MAJOR AND OUTCOME
program boot, rclass
	syntax varlist(numeric) [if] [in]
	*SYNTAX - FIRST VARIABLE IS OUTCOME , SECOND IS MAJOR, THIRD IS COMPARISON, REST IS CONTROLS FOR DETERMINING PROPENSITY TO ENTER MAJOR
	tokenize `varlist'
	local outcome `1'
	macro shift
	local major `1'
	macro shift
	local comparison `1'
	macro shift
	local xvars `*'
	capture drop phat wgt
	logit `major' `xvars' 
	predict phat, pr
	gen wgt=phat/(1-phat)
	
	* Calculate Deciles *
	_pctile `outcome' if `major'==1, nq(10)
	forval x=1(1)9{
	return scalar major_`x'0=r(r`x')
	}
	
	*LIBERAL ARTS DISTRIBUTION IS WEIGHTED TOWARDS STUDENTS WITH HIGH EX-ANTE PROPENSITY TO ENTER THE SPECIFIED MAJOR
	_pctile `outcome' if `comparison'==1 [aw=wgt], nq(10)
	forval x=1(1)9{
	return scalar lib_`x'0=r(r`x')
	}
end


postfile figureobs str40(figurename) float(observations) using "$tables/figure_observations.dta", replace



/** SECTION 2: FOUR-YEAR INSTITUTIONS **/ 

**FULL SAMPLE**

**# Bookmark #1
cap rm "$tables/qte_bootstrap_data_4yr.dta"
input quantile qte_bootstrap_mean ub lb qte str10(major relmajor)
. . . . . . . 
end
saveold "$tables/qte_bootstrap_data_4yr.dta", replace

*LOOP OVER MAJORS AND OUTCOMES AND CONDUCT BOOTSTRAPPED QTE CALCULATIONS
use "$data/collapsed_data_4yr", clear


*GENERATE LAST COLLEGE-BY-MAJOR INDICATOR FOR CLUSTERING (SAI - 4/24/2023)
gen majors_cluster = .
global temp = 1
foreach major in `majors_4yr' {
	replace majors_cluster = $temp if `major' == 1
	global temp = $temp + 1
}
global drop temp 

gen double inst_major = last_col_4yr*100+	majors_cluster
sum inst_major, detail


*ABOUT 700 OBS ARE MISSING A MAJOR - JUST DROP THESE
drop if inst_major == .
	
foreach outcome of varlist  wbar_wage {
	*wbar_ma_4  coeff_var_ma_4_trend coeff_var_wagehat_trend

	
	*CREATE NAMES TO USE IN FIGURES
	if "`outcome'" == "wbar_wage" local outcome_name = "Mean Earnings"
	if "`outcome'" == "coeff_var_ma_4_trend" local outcome_name = "Coeff of Variation"	
	if "`outcome'" == "coeff_var_wagehat_trend" local outcome_name = "Coeff of Variation"	

  foreach major_choice of varlist `majors_4yr' {
		
		cap graph drop *
		
	  foreach relative_major of varlist lib_4yr eng_4yr it_4yr {
	
		if "`major_choice'" == "`relative_major'" continue
		if "`major_choice'" == "ag_4yr" &  "`relative_major'" != "lib_4yr" continue
		if "`major_choice'" == "com_4yr" &  "`relative_major'" != "lib_4yr" continue
		if "`major_choice'" == "it_4yr" &  "`relative_major'" != "lib_4yr" & "`relative_major'" != "eng_4yr" continue
		if "`major_choice'" == "voc_4yr" &  "`relative_major'" != "lib_4yr" continue
		if "`major_choice'" == "eng_4yr" &  "`relative_major'" != "lib_4yr" continue
		if "`major_choice'" == "bio_4yr" &  "`relative_major'" != "lib_4yr" & "`relative_major'" != "eng_4yr"  continue
		if "`major_choice'" == "sci_4yr" &  "`relative_major'" != "lib_4yr" continue
		if "`major_choice'" == "soc_4yr" &  "`relative_major'" != "lib_4yr" continue
		if "`major_choice'" == "bus_4yr" &  "`relative_major'" != "lib_4yr" & "`relative_major'" != "eng_4yr" & "`relative_major'" != "it_4yr" continue
		if "`major_choice'" == "und_4yr" &  "`relative_major'" != "lib_4yr" continue
		
		
		 
		*LABELS FOR GRAPHS
		if "`relative_major'" == "lib_4yr" local reltitle = ""
		if "`relative_major'" == "eng_4yr" local reltitle = "vs Engineering"
		if "`relative_major'" == "it_4yr" local reltitle = "vs Information Tech"
		
		
		*CREATE NAMES TO USE IN FIGURES
		if "`major_choice'" == "ag_4yr"  local major_name = "Agriculture"
		if "`major_choice'" == "com_4yr" local major_name = "Communications"
		if "`major_choice'" == "it_4yr"  local major_name = "Information Tech"
		if "`major_choice'" == "voc_4yr" local major_name = "Vocational"
		if "`major_choice'" == "eng_4yr" local major_name = "Engineering"	
		if "`major_choice'" == "bio_4yr" local major_name = "Biology"
		if "`major_choice'" == "sci_4yr" local major_name = "Sciences"
		if "`major_choice'" == "soc_4yr" local major_name = "Social Sciences"
		if "`major_choice'" == "bus_4yr" local major_name = "Business and Economics"
		if "`major_choice'" == "und_4yr" local major_name = "Undeclared"

		if "`relative_major'" == "ag_4yr"  local relmajor_name = "Agriculture"
		if "`relative_major'" == "com_4yr" local relmajor_name = "Communications"
		if "`relative_major'" == "it_4yr"  local relmajor_name = "Information Tech"
		if "`relative_major'" == "voc_4yr" local relmajor_name = "Vocational"
		if "`relative_major'" == "eng_4yr" local relmajor_name = "Engineering"	
		if "`relative_major'" == "bio_4yr" local relmajor_name = "Biology"
		if "`relative_major'" == "sci_4yr" local relmajor_name = "Sciences"
		if "`relative_major'" == "soc_4yr" local relmajor_name = "Social Sciences"
		if "`relative_major'" == "bus_4yr" local relmajor_name = "Business and Economics"
		if "`relative_major'" == "lib_4yr" local relmajor_name = "Liberal Arts"
		if "`relative_major'" == "und_4yr" local relmajor_name = "Undeclared"
		
	
	
preserve
keep if `major_choice'==1 | `relative_major'==1
count
local obs = r(N)



# delimit ;
bootstrap  major_10=r(major_10) major_20=r(major_20) major_30=r(major_30) major_40=r(major_40) major_50=r(major_50) major_60=r(major_60) major_70=r(major_70) major_80=r(major_80) major_90=r(major_90) lib_10=r(lib_10) lib_20=r(lib_20) lib_30=r(lib_30) lib_40=r(lib_40) lib_50=r(lib_50) lib_60=r(lib_60) lib_70=r(lib_70) lib_80=r(lib_80) lib_90=r(lib_90),
	   reps($reps) nodrop cluster(inst_major) saving("$output_results/qte_`major_choice'_`relative_major'_`outcome'.dta", replace):
	   boot `outcome' `major_choice' `relative_major' `controls';
# delimit cr

* Generate QTE and SEs *
use "$output_results/qte_`major_choice'_`relative_major'_`outcome'", clear
gen trial=_n

forval x=10(10)90{
gen qte_`x'=major_`x'-lib_`x'
_pctile qte_`x', p(2.5)
gen lb_`x'=r(r1)
_pctile qte_`x', p(97.5)
gen ub_`x'=r(r1)
}

reshape long qte_ lb_ ub_ major_ lib_, i(trial) j(quantile)
ren qte_ qte
ren ub_ ub
ren lb_ lb
ren major_ maj
ren lib_ lib

collapse (mean)  qte ub lb, by(quantile)

   *INPUT ACTUAL VALUES (PREVIOUSLY WAS USING AVG OF BOOTSTRAPS) SAI 8-14-23
    rename qte qte_bootstrap_mean
    gen qte = .
    gen major_wage = .
    gen relmajor_wage = .
    gen obs = `obs'
    forvalues pctl = 10(10)90 {
	replace qte = _b[major_`pctl'] - _b[lib_`pctl'] if quantile == `pctl'
	replace major_wage = _b[major_`pctl'] if quantile == `pctl'
 	replace relmajor_wage = _b[lib_`pctl'] if quantile == `pctl'
   }
    list
    gen major = "`major_choice'"
    gen relmajor = "`relative_major'"
    saveold "$tables/qte_`major_choice'_`relative_major'_`outcome'_4yr", replace


gen yline = 0
twoway  rarea ub lb quantile, astyle(ci) || connect qte quantile, msymbol(none) lcolor(navy) scheme(s1color) xtitle("Percentile") xlabel(10(10)90, angle(45)) legend(off) title("`major_name'" "`reltitle'", size(medsmall)) ylabel(,angle(45)) ||  connect yline quantile, lcolor(maroon) msymbol(none)
graph rename qte_`major_choice'_`relative_major'
graph save "$plots/qte_`major_choice'_`relative_major'_`outcome'", replace
graph export "$plots/qte_`major_choice'_`relative_major'_`outcome'.pdf", replace
post figureobs ("qte_`major_choice'_`relative_major'_`outcome'") (`obs')

    use "$tables/qte_bootstrap_data_4yr.dta", clear
    append using "$tables/qte_`major_choice'_`relative_major'_`outcome'_4yr"
    saveold "$tables/qte_bootstrap_data_4yr", replace

restore



}


if "`outcome'" == "wbar_wage" {
	local ytitle1 "Quarterly Mean Earnings" 
	local ytitle2 ""
}

if "`outcome'" == "coeff_var_ma4_trend" {
	local ytitle1 "Coefficient of Variation" 
	local ytitle2 "Using 4 Quarter Moving Average of Earnings"
}

if "`outcome'" == "coeff_var_wagehat_trend" {
	local ytitle1 "Coefficient of Variation" 
	local ytitle2 "Using Quarterly Earnings"
}



}

}


*GRAPH EACH MAJOR RELATIVE TO LIBERAL ARTS
global figure_combine = ""

foreach major in `majors_4yr' {
if "`major'" == "lib_4yr" continue
global figure_combine = "$figure_combine" + "$plots/qte_`major'_lib_4yr_wbar_wage.gph "
}

# delimit ;
graph combine $figure_combine, title("Quantile Treatment Effects Estimates" "Relative to Liberal Arts, Four-Year Institutions", size(medlarge)) graphregion(color(white)) ycommon l2title("`ytitle1'", size(medsmall)) l1title("`ytitle2'", size(medsmall)) ;
# delimit cr

graph save "$plots/qte_4yr.gph", replace
graph export "$plots/qte_4yr.pdf", as(pdf) replace
graph close _all


*/





/** SECTION 3: TWO YEAR INSTITUTIONS **/ 

** FULL SAMPLE**
clear  

cap rm "$tables/qte_bootstrap_data_2yr.dta"
input quantile qte_bootstrap_mean ub lb qte str10(major relmajor)
. . . . . . . 
end
saveold "$tables/qte_bootstrap_data_2yr.dta", replace

*LOOP OVER MAJORS AND OUTCOMES AND CONDUCT BOOTSTRAPPED QTE CALCULATIONS
use "$data/collapsed_data_2yr", clear


*GENERATE LAST COLLEGE-BY-MAJOR INDICATOR FOR CLUSTERING (SAI - 4/24/2023)
gen majors_cluster = .
global temp = 1
foreach major in `majors_2yr' {
	replace majors_cluster = $temp if `major' == 1
	global temp = $temp + 1
}
global drop temp 

gen double inst_major = last_col_2yr*100+	majors_cluster
sum inst_major, detail


*ABOUT 700 OBS ARE MISSING A MAJOR - JUST DROP THESE
drop if inst_major == .
	
	
foreach outcome of varlist  wbar_wage {
	*wbar_ma_4  coeff_var_ma_4_trend coeff_var_wagehat_trend

	
	*CREATE NAMES TO USE IN FIGURES
	if "`outcome'" == "wbar_wage" local outcome_name = "Mean Earnings"
	if "`outcome'" == "coeff_var_ma_4_trend" local outcome_name = "Coeff of Variation"	
	if "`outcome'" == "coeff_var_wagehat_trend" local outcome_name = "Coeff of Variation"	

  foreach major_choice of varlist `majors_2yr' {
		
		cap graph drop *
		
	foreach relative_major of varlist lib_2yr soc_2yr it_2yr bio_2yr {
	
		if "`major_choice'" == "`relative_major'" continue
		if "`major_choice'" == "ag_2yr" &  "`relative_major'" != "lib_2yr" continue
		if "`major_choice'" == "com_2yr" &  "`relative_major'" != "lib_2yr" continue
		if "`major_choice'" == "it_2yr" &  "`relative_major'" != "lib_2yr"  continue
		if "`major_choice'" == "voc_2yr" &  "`relative_major'" != "lib_2yr" & "`relative_major'" != "it_2yr" & "`relative_major'" != "bio_2yr"  continue
		if "`major_choice'" == "eng_2yr" &  "`relative_major'" != "lib_2yr" continue
		if "`major_choice'" == "bio_2yr" &  "`relative_major'" != "lib_2yr" continue
		if "`major_choice'" == "sci_2yr" &  "`relative_major'" != "lib_2yr" continue
		if "`major_choice'" == "soc_2yr" &  "`relative_major'" != "lib_2yr" continue
		if "`major_choice'" == "bus_2yr" &  "`relative_major'" != "lib_2yr" continue
		if "`major_choice'" == "educ_2yr" &  "`relative_major'" != "lib_2yr" & "`relative_major'" != "soc_2yr"  & "`relative_major'" != "bio_2yr" continue
		if "`major_choice'" == "und_2yr" &  "`relative_major'" != "lib_2yr" continue
		
	*LABELS FOR GRAPHS
	if "`relative_major'" == "lib_2yr" local reltitle = ""
	if "`relative_major'" == "it_2yr" local reltitle = "vs Information Tech"
	if "`relative_major'" == "bio_2yr" local reltitle = "vs Biology/Health"
	if "`relative_major'" == "soc_2yr" local reltitle = "vs Social Science"
	

	
	*CREATE NAMES TO USE IN FIGURES
	if "`major_choice'" == "ag_2yr"  local major_name = "Agriculture"
	if "`major_choice'" == "com_2yr" local major_name = "Communications"
	if "`major_choice'" == "it_2yr"  local major_name = "Information Tech"
	if "`major_choice'" == "voc_2yr" local major_name = "Vocational"
	if "`major_choice'" == "eng_2yr" local major_name = "Engineering"	
	if "`major_choice'" == "bio_2yr" local major_name = "Biology"
	if "`major_choice'" == "sci_2yr" local major_name = "Sciences"
	if "`major_choice'" == "soc_2yr" local major_name = "Social Sciences"
	if "`major_choice'" == "bus_2yr" local major_name = "Business and Economics"
	if "`major_choice'" == "educ_2yr" local major_name = "Education"
	if "`major_choice'" == "und_2yr" local major_name = "Undeclared"

	if "`relative_major'" == "ag_2yr"  local relmajor_name = "Agriculture"
	if "`relative_major'" == "com_2yr" local relmajor_name = "Communications"
	if "`relative_major'" == "it_2yr"  local relmajor_name = "Information Tech"
	if "`relative_major'" == "voc_2yr" local relmajor_name = "Vocational"
	if "`relative_major'" == "eng_2yr" local relmajor_name = "Engineering"	
	if "`relative_major'" == "bio_2yr" local relmajor_name = "Biology"
	if "`relative_major'" == "sci_2yr" local relmajor_name = "Sciences"
	if "`relative_major'" == "soc_2yr" local relmajor_name = "Social Sciences"
	if "`relative_major'" == "bus_2yr" local relmajor_name = "Business and Economics"
	if "`relative_major'" == "lib_2yr" local relmajor_name = "Liberal Arts"
	if "`relative_major'" == "educ_2yr" local relmajor_name = "Education"
	if "`relative_major'" == "und_2yr" local relmajor_name = "Undeclared"
	
	
	
preserve
keep if `major_choice'==1 | `relative_major'==1
count
local obs = r(N)

# delimit ;
bootstrap  major_10=r(major_10) major_20=r(major_20) major_30=r(major_30) major_40=r(major_40) major_50=r(major_50) major_60=r(major_60) major_70=r(major_70) major_80=r(major_80) major_90=r(major_90) lib_10=r(lib_10) lib_20=r(lib_20) lib_30=r(lib_30) lib_40=r(lib_40) lib_50=r(lib_50) lib_60=r(lib_60) lib_70=r(lib_70) lib_80=r(lib_80) lib_90=r(lib_90),
	   reps($reps) nodrop cluster(inst_major) saving("$output_results/qte_`major_choice'_`relative_major'_`outcome'.dta", replace):
	   boot `outcome' `major_choice' `relative_major' `controls';
# delimit cr

* Generate QTE and SEs *
use "$output_results/qte_`major_choice'_`relative_major'_`outcome'", clear
gen trial=_n

forval x=10(10)90{
gen qte_`x'=major_`x'-lib_`x'
_pctile qte_`x', p(2.5)
gen lb_`x'=r(r1)
_pctile qte_`x', p(97.5)
gen ub_`x'=r(r1)
}

reshape long qte_ lb_ ub_ major_ lib_, i(trial) j(quantile)
ren qte_ qte
ren ub_ ub
ren lb_ lb
ren major_ major
ren lib_ lib
collapse (mean)  qte ub lb, by(quantile)

   *INPUT ACTUAL VALUES (PREVIOUSLY WAS USING AVG OF BOOTSTRAPS) SAI 8-14-23
    rename qte qte_bootstrap_mean
    gen qte = .
    gen major_wage = .
    gen relmajor_wage = .
    gen obs = `obs'
    forvalues pctl = 10(10)90 {
	replace qte = _b[major_`pctl'] - _b[lib_`pctl'] if quantile == `pctl'
	replace major_wage = _b[major_`pctl'] if quantile == `pctl'
 	replace relmajor_wage = _b[lib_`pctl'] if quantile == `pctl'
   }
    list
    gen major = "`major_choice'"
    gen relmajor = "`relative_major'"
    saveold "$tables/qte_`major_choice'_`relative_major'_`outcome'_2yr", replace


gen yline = 0
twoway  rarea ub lb quantile, astyle(ci) || connect qte quantile, msymbol(none) lcolor(navy) scheme(s1color) xtitle("Percentile") xlabel(10(10)90, angle(45)) legend(off) title("`major_name'" "`reltitle'", size(medsmall)) ylabel(,angle(45)) ||  connect yline quantile, lcolor(maroon) msymbol(none)
graph rename qte_`major_choice'_`relative_major'
graph save "$plots/qte_`major_choice'_`relative_major'_`outcome'", replace
graph export "$plots/qte_`major_choice'_`relative_major'_`outcome'.pdf", replace


    use "$tables/qte_bootstrap_data_2yr.dta", clear
    append using "$tables/qte_`major_choice'_`relative_major'_`outcome'_2yr"	
    saveold "$tables/qte_bootstrap_data_2yr", replace
    
post figureobs ("qte_`major_choice'_`relative_major'_`outcome'") (`obs')


restore


}


if "`outcome'" == "wbar_wage" {
	local ytitle1 "Quarterly Mean Earnings" 
	local ytitle2 ""
}


if "`outcome'" == "coeff_var_ma4_trend" {
	local ytitle1 "Coefficient of Variation" 
	local ytitle2 "Using 4 Quarter Moving Average of Earnings"
}

if "`outcome'" == "coeff_var_wagehat_trend" {
	local ytitle1 "Coefficient of Variation" 
	local ytitle2 "Using Quarterly Earnings"
}

}
}




*GRAPH EACH MAJOR RELATIVE TO LIBERAL ARTS
global figure_combine = ""
local majors_2yr "ag_2yr bio_2yr bus_2yr com_2yr educ_2yr eng_2yr it_2yr lib_2yr sci_2yr soc_2yr und_2yr voc_2yr"

foreach major in `majors_2yr' {
if "`major'" == "lib_2yr" continue
global figure_combine = "$figure_combine" + "$plots/qte_`major'_lib_2yr_wbar_wage.gph "
}

# delimit ;
graph combine $figure_combine, title("Quantile Treatment Effects Estimates" "Relative to Liberal Arts, Two-Year Institutions", size(medlarge)) graphregion(color(white)) ycommon l2title("`ytitle1'", size(medsmall)) l1title("`ytitle2'", size(medsmall)) ;
# delimit cr

graph save "$plots/qte_2yr.gph", replace
graph export "$plots/qte_2yr.pdf", as(pdf) replace
graph close _all


*GRAPH FOR OTHER INTERESTING COMPARISONS
global figure_combine = ""
foreach graph in "bus_4yr_eng_4yr" "bus_4yr_it_4yr" "it_4yr_eng_4yr" "bio_4yr_eng_4yr" {
	global figure_combine = "$figure_combine" + "$plots/qte_`graph'_wbar_wage.gph "
}

# delimit ;
graph combine $figure_combine, title("Other Quantile Treatment Effects Estimates" "Four-Year Institutions", size(medlarge)) graphregion(color(white))  l2title("`ytitle1'", size(medsmall)) l1title("`ytitle2'", size(medsmall)) ;
# delimit cr

graph save "$plots/qte_4yr_other.gph", replace
graph export "$plots/qte_4yr_other.pdf", as(pdf) replace

global figure_combine = ""
foreach graph in "voc_2yr_it_2yr" "voc_2yr_bio_2yr" "educ_2yr_soc_2yr" "educ_2yr_bio_2yr" {
	global figure_combine = "$figure_combine" + "$plots/qte_`graph'_wbar_wage.gph "
}

# delimit ;
graph combine $figure_combine, title("Other Quantile Treatment Effects Estimates" "Two-Year Institutions", size(medlarge)) graphregion(color(white))  l2title("`ytitle1'", size(medsmall)) l1title("`ytitle2'", size(medsmall)) ;
# delimit cr

graph save "$plots/qte_2yr_other.gph", replace
graph export "$plots/qte_2yr_other.pdf", as(pdf) replace

postclose figureobs


graph close _all

capture log close
*/

/*
/** SECTION 4: UPDATING FIGURES TO MAKE SAME SCALE **/ 
/* FOUR YEAR */ 

foreach major_choice in ag_4yr com_4yr it_4yr voc_4yr eng_4yr bio_4yr sci_4yr soc_4yr bus_4yr und_4yr {
	
	*CREATE NAMES TO USE IN FIGURES
	if "`major_choice'" == "ag_4yr" local major_name = "Agriculture"
	if "`major_choice'" == "com_4yr" local major_name = "Communications"
	if "`major_choice'" == "it_4yr" local major_name = "Information Tech"
	if "`major_choice'" == "voc_4yr" local major_name = "Vocational"
	if "`major_choice'" == "eng_4yr" local major_name = "Engineering"	
	if "`major_choice'" == "bio_4yr" local major_name = "Biology"
	if "`major_choice'" == "sci_4yr" local major_name = "Sciences"
	if "`major_choice'" == "soc_4yr" local major_name = "Social Sciences"
	if "`major_choice'" == "bus_4yr" local major_name = "Business and Economics"
	if "`major_choice'" == "und_4yr" local major_name = "Undeclared"


use "$tables/qte_`major_choice'_wbar_ma_4_4yr.dta", clear 


collapse (mean) qte ub lb, by(quantile)
twoway connect qte quantile, msymbol(none) lcolor(navy) || connect ub quantile, msymbol(none) lpattern(dot) lcolor(maroon) || connect lb quantile, msymbol(none) lpattern(dot) lcolor(maroon) ||, scheme(s1color) xtitle("Percentile") xlabel(10(10)90, angle(45)) legend(off) title("`major_name'") yline(0) ylabel(0(5000)15000,angle(45)) yscale(range(-500 15000))
graph rename qte_`major_choice'
graph save "$plots/qte_`major_choice'_ma4_4yr", replace
graph export "$plots/qte_`major_choice'_ma4_4yr.pdf", replace
}

/* TWO YEAR */ 
foreach major_choice in ag_2yr com_2yr it_2yr voc_2yr eng_2yr bio_2yr sci_2yr soc_2yr bus_2yr educ_2yr und_2yr {
	
	*CREATE NAMES TO USE IN FIGURES
	if "`major_choice'" == "ag_2yr" local major_name = "Agriculture"
	if "`major_choice'" == "com_2yr" local major_name = "Communications"
	if "`major_choice'" == "it_2yr" local major_name = "Information Tech"
	if "`major_choice'" == "voc_2yr" local major_name = "Vocational"
	if "`major_choice'" == "eng_2yr" local major_name = "Engineering"	
	if "`major_choice'" == "bio_2yr" local major_name = "Biology"
	if "`major_choice'" == "sci_2yr" local major_name = "Sciences"
	if "`major_choice'" == "soc_2yr" local major_name = "Social Sciences"
	if "`major_choice'" == "bus_2yr" local major_name = "Business and Economics"
	if "`major_choice'" == "educ_2yr" local major_name = "Education"
	if "`major_choice'" == "und_2yr" local major_name = "Undeclared"


use "$tables/qte_`major_choice'_wbar_ma_4_2yr", clear 

collapse (mean) qte ub lb, by(quantile)
twoway connect qte quantile, msymbol(none) lcolor(navy) || connect ub quantile, msymbol(none) lpattern(dot) lcolor(maroon) || connect lb quantile, msymbol(none) lpattern(dot) lcolor(maroon) ||, scheme(s1color) xtitle("Percentile") xlabel(10(10)90, angle(45)) legend(off) title("`major_name'") yline(0) ylabel(-2000(2000)4000,angle(45)) yscale(range(-2000 4000))
graph rename qte_`major_choice'
graph save "$plots/qte_`major_choice'_ma4_2yr", replace
graph export "$plots/qte_`major_choice'_ma4_2yr.pdf", replace
}


/** END **/ 
